<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<div class="row">
	<div class="col-md-12 col-lg-12">
		<div class="theory-lab-title">
			<ul>
				<li class="get-theory">理论课</li>
				<li class="get-lab">实验课</li>
				<shiro:hasRole name="teacher">
					<li class="new-lesson">新建课堂</li>
				</shiro:hasRole>
			</ul>
		</div>
	</div>
	<div class="col-md-12 col-lg-12">
		<!--理论课 -->
		<div class="theory-list">
			<ul id="theoryList">
				
			</ul>
		</div>
		<!--实验课 -->
		<div class="lab-list">
			<ul id="labList">
			
			</ul>
			
		</div>
		<div class="page-content" id="lessonPage">
			<nav class="pagination" role="navigation">
				<a class="last-page">
					<i class="fa fa-angle-left"></i>
				</a>
				<span class="page-number">../..</span>
				<a class="next-page">
					<i class="fa fa-angle-right"></i>
				</a>
			</nav>
		</div>
	</div>
	
	
	<!-- 新建课堂 -->
	<div class="modal fade" id="newLesson">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title" style="display:inline;float:left;">新建课堂</h4>
					<button type="button" class="close" data-dismiss="modal" style="display:inline;float:right;">&times;</button>
				</div>
				<div class="modal-body">
					<div class="row">
						<div class="col-xs-12">
							<label>课堂类型</label>
							<select class="form-control" id="createLessonType">
								<option value="THEORY" selected="selected">理论课</option>
								<option value="LAB">实验课</option>
							</select>
						</div>
						<div class="col-xs-12">
							<label>开始时间</label>
							<input type="datetime-local" class="form-control" name="createBeginDate">
						</div>
						<div class="col-xs-12">
							<label>结束时间</label>
							<input type="datetime-local" class="form-control" name="createEndDate">
						</div>
						<div class="col-xs-12">
							<label>上课地点</label>
							<input type="text" class="form-control" name="createLocation">
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" id="createLessonButton">确定</button>
				</div>
			</div>
		</div>
	</div>
	
</div>

<script>

	$(function() {
		$(".new-lesson").click(function() {
			$("#newLesson").modal("show");
		});
		$("#createLessonButton").click(createLesson);
	})
	
	
	var createLesson = function(){
		var lessonType=$("#createLessonType  option:selected").val();
		var beginDate = parseDate($("input[name='createBeginDate']").val());
		var endDate = parseDate($("input[name='createEndDate']").val());
		var location = $("input[name='createLocation']").val();
		var json={
				classId:data.data.classView.id,
				type:lessonType,
				beginDate:beginDate,
				endDate:endDate,
				location:location
		};
		$.post(CONTEXT_PATH+"lesson/ajaxCreate", {
			data : JSON.stringify(json)
		}, function(data) {
			if(data.status=="success"){
				window.location.reload();
			}else{
				alert("请检查课堂信息！");
			}
		});
	}

</script>